package com.samsung.common.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CalculatePage {
	/**
	 * 对List的分页工具类
	 * */
	public static Map<String, Integer> getPageData(List<?> list,int currentPage,int pageSize) {
		Map<String, Integer> resultMap=new HashMap<String, Integer>();
		int totalSize = list.size();
		int totalPage = totalSize%pageSize==0?totalSize/pageSize:totalSize/pageSize+1;
		if(totalPage==0){
			totalPage=1;
		}
		int startIndex=currentPage*pageSize;
		resultMap.put("startIndex", startIndex);
		resultMap.put("currentPage",currentPage);
		resultMap.put("totalPage",totalPage);		
		return resultMap;
	}
}
